<div class="info-w3l" id="register">
	<h2 class="wthree">注册</h2>
	<form action="javascript:void(0)"  class="form-agileits">
		<input type="text" v-model="user.userName" id="username"  placeholder="请输入用户名"  required="">
		<input type="password" v-model="user.password" id="password"  placeholder="请输入密码"  required="">

		<!--<input type="email" id="email" name="email" placeholder="mail@example.com" title="Please enter a Valid Email Address" required="">
		<textarea id="message" name="message" placeholder="Your Message" title="Please enter Your Comments"></textarea>-->
		<input type="submit" @click="register()" class="sign-in" value="Submit">
	</form>
	<p class="agileinfo">Or</p>
	<ul class="social-w3-agileits">
		<li><a href="#"><i class="fa fa-facebook"></i></a></li>
		<li><a href="#"><i class="fa fa-twitter"></i></a></li>
		<li><a href="#"><i class="fa fa-google-plus"></i></a></li>
		<li><a href="#"><i class="fa fa-linkedin"></i></a></li>
	</ul>
</div>

<script>
	var registerVue = new Vue({
		el:"#register",
		data: {
			user:{
				userName: "",
				password: "",
			},

		},
		methods: {
			register: function () {
				if (this.user.userName == "" || this.user.password ==""){
					layer.msg("请输入用户名或密码！！！", { icon: 0 });
					return;
				}
				var self = this;/*-------利于处理success-------*/
				$.ajax({
					url:"/api/user",
					type:"post",
					contentType:"application/json",
					data:JSON.stringify(self.user),
					success: function (result) {
						if(result.status == 500){
							layer.msg(result.message,{ icon:0 });
						}else {
							layer.msg("注册成功！",{ icon:0 });
							window.location.href="/login"
						}
					},
					error: function (errorMs,result) {
						layer.error(result.message,{icon:0});

					}

				});
			}
		}
	});
</script>